﻿using ShopSystem.Model.Entities.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShopSystem.Core.Base.Repository.Base
{
    public interface IBaseRepository<TEntity> where TEntity : BaseEntity
    {
        /// <summary>
        /// get all the information
        /// </summary>
        /// <returns></returns>
        Task<IQueryable<TEntity>> Query();

        /// <summary>
        /// get the information by id
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        Task<TEntity> Query(int id);

        /// <summary>
        /// delete obj by Id
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        Task Delete(int id, bool saved = true);

        /// <summary>
        /// Adding data to a table now,if once is false it will not immediately
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="saved"></param>
        /// <returns></returns>
        Task Insert(TEntity obj, bool saved = true);

        /// <summary>
        /// Modify table data now,if once is false it will not immediately
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="saved"></param>
        /// <returns></returns>
        Task Update(TEntity obj, bool saved = true);

        /// <summary>
        /// Save the changes now
        /// </summary>
        /// <returns></returns>
        Task SaveChanges();
    }
}
